package com.develop.skwen.electricgomall.home.list.holder;

import android.support.annotation.NonNull;
import android.view.View;

import com.develop.skwen.basemodule.list.BaseHolder;
import com.develop.skwen.electricgomall.R;
import com.develop.skwen.electricgomall.home.model.HomeData;
import com.develop.skwen.electricgomall.util.GlideImageLoader;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;

/**
 * Created by skwen
 * on 18-5-30
 */

public class AdHolder extends BaseHolder<HomeData> {


    private Banner mBanner;


    public AdHolder(View itemView) {
        super(itemView);
        mBanner = findViewById(R.id.item_banner);
    }

    @Override
    public void bind(@NonNull HomeData item) {

        if (item.getAd_images() != null && item.getAd_images().size() > 0){

            //设置banner样式
            mBanner.setBannerStyle(BannerConfig.NUM_INDICATOR);
            //设置图片加载器
            mBanner.setImageLoader(new GlideImageLoader());
            //设置图片集合
            mBanner.setImages(item.getAd_images());
            //设置banner动画效果
            mBanner.setBannerAnimation(Transformer.DepthPage);
            //设置标题集合（当banner样式有显示title时）
//        mBanner.setBannerTitles(titles);
            //设置自动轮播，默认为true
            mBanner.isAutoPlay(true);
            //设置轮播时间
            mBanner.setDelayTime(1500);
            //设置指示器位置（当banner模式中有指示器时）
            mBanner.setIndicatorGravity(BannerConfig.CENTER);
            //banner设置方法全部调用完毕时最后调用
            mBanner.start();
        }
    }
}
